package com.hdax.dm.controller;

import com.hdax.dm.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

@RestController
public class PayController {

    @Autowired
    private PayService payService;

    @GetMapping(path = "/{orderNo}")
    public String pay(@PathVariable("orderNo") String orderNo) throws Exception{
        //tmmxat4872@sandbox.com
        //111111
        return payService.pay(orderNo);
    }

    @PostMapping(path = "/success")
    public RedirectView success(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        return payService.success(request, response);
    }

}
